var convert_table = {
	//相对分子质量
	A: {
		C_methane: 16.04, //甲烷
		C_ethane: 30.07, //乙烷
		C_propane: 44.1, //丙烷
		C_propylene: 42.08, //丙烯
		C_Isobutane: 58.12, //异丁烷
		C_N_butane: 58.12, //正丁烷
		C_Trans_2_butene: 56.11, //反丁烯
		C_1_butene: 56.11, //正丁烯
		C_isobutene: 56.11, //异丁烯
		C_Cis_2_butene: 56.11, //顺丁烯
		C_1_Pentene: 70.13, //正戊烯
		C_2_methyl_1_butene: 70.13, //2_甲基_1_丁烯
		C_Trans_2_pentene: 70.13, //反_2_戊烯
		C_Cis_2_pentene: 70.13, //顺_2_戊烯
		C_2_methyl_2_butene: 70.13, //二甲基乙烯
		C_Isopentane: 72.15, //异戊烷
		C_N_pentane: 72.15 //正戊烷
	},
	//液体体积
	B: {
		C_methane: 0.00226, //甲烷
		C_ethane: 0.003548, //乙烷
		C_propane: 0.003675, //丙烷
		C_propylene: 0.003413, //丙烯
		C_Isobutane: 0.004362, //异丁烷
		C_N_butane: 0.004205, //正丁烷
		C_Trans_2_butene: 0.003887, //反丁烯
		C_1_butene: 0.003944, //正丁烯
		C_isobutene: 0.003949, //异丁烯
		C_Cis_2_butene: 0.00378, //顺丁烯
		C_1_Pentene: 0.004589, //正戊烯
		C_2_methyl_1_butene: 0.004519, //2_甲基_1_丁烯
		C_Trans_2_pentene: 0.004537, //反_2_戊烯
		C_Cis_2_pentene: 0.004482, //顺_2_戊烯
		C_2_methyl_2_butene: 0.00447, //二甲基乙烯
		C_Isopentane: 0.004882, //异戊烷
		C_N_pentane: 0.00483, //正戊烷
	},
	//相对密度
	C: {
		C_methane: 0.3, //甲烷
		C_ethane: 0.3581, //乙烷
		C_propane: 0.507, //丙烷
		C_propylene: 0.521, //丙烯
		C_Isobutane: 0.5629, //异丁烷
		C_N_butane: 0.584, //正丁烷
		C_Trans_2_butene: 0.61, //反丁烯
		C_1_butene: 0.6011, //正丁烯
		C_isobutene: 0.6004, //异丁烯
		C_Cis_2_butene: 0.6272, //顺丁烯
		C_1_Pentene: 0.6457, //正戊烯
		C_2_methyl_1_butene: 0.6557, //2_甲基_1_丁烯
		C_Trans_2_pentene: 0.653, //反_2_戊烯
		C_Cis_2_pentene: 0.6611, //顺_2_戊烯
		C_2_methyl_2_butene: 0.663, //二甲基乙烯
		C_Isopentane: 0.6244, //异戊烷
		C_N_pentane: 0.6311, //正戊烷
	}

};
var calc_table = {
	//蒸气压
	A: {
		C_methane: '', //甲烷
		C_ethane: 4826, //乙烷
		C_propane: 1200, //丙烷
		C_propylene: 1469, //丙烯
		C_Isobutane: 400, //异丁烷
		C_N_butane: 255, //正丁烷
		C_Trans_2_butene: 344, //反丁烯
		C_1_butene: 445, //正丁烯
		C_isobutene: 436, //异丁烯
		C_Cis_2_butene: 315, //顺丁烯
		C_1_Pentene: 132, //正戊烯
		C_2_methyl_1_butene: 126, //2_甲基_1_丁烯
		C_Trans_2_pentene: 106, //反_2_戊烯
		C_Cis_2_pentene: 104, //顺_2_戊烯
		C_2_methyl_2_butene: 99, //二甲基乙烯
		C_Isopentane: 141, //异戊烷
		C_N_pentane: 107, //正戊烷

	},
	//相对密度
	B: {
		C_methane: '', //甲烷
		C_ethane: 0.35619, //乙烷
		C_propane: 0.50699, //丙烷
		C_propylene: 0.52095, //丙烯
		C_Isobutane: 0.56287, //异丁烷
		C_N_butane: 0.58401, //正丁烷
		C_Trans_2_butene: 0.6112, //反丁烯
		C_1_butene: 0.6013, //正丁烯
		C_isobutene: 0.6005, //异丁烯
		C_Cis_2_butene: 0.6286, //顺丁烯
		C_1_Pentene: 0.6458, //正戊烯
		C_2_methyl_1_butene: 0.6563, //2_甲基_1_丁烯
		C_Trans_2_pentene: 0.6524, //反_2_戊烯
		C_Cis_2_pentene: 0.6598, //顺_2_戊烯
		C_2_methyl_2_butene: 0.6683, //二甲基乙烯
		C_Isopentane: 0.6247, //异戊烷
		C_N_pentane: 0.6311, //正戊烷

	},
	//MON
	C: {
		C_methane: '', //甲烷
		C_ethane: 99.2, //乙烷
		C_propane: 97.1, //丙烷
		C_propylene: 84.9, //丙烯
		C_Isobutane: 97.6, //异丁烷
		C_N_butane: 89.6, //正丁烷
		C_Trans_2_butene: '', //反丁烯
		C_1_butene: 80.8, //正丁烯
		C_isobutene: '', //异丁烯
		C_Cis_2_butene: 83.5, //顺丁烯
		C_1_Pentene: 77.1, //正戊烯
		C_2_methyl_1_butene: 81.9, //2_甲基_1_丁烯
		C_Trans_2_pentene: '', //反_2_戊烯
		C_Cis_2_pentene: '', //顺_2_戊烯
		C_2_methyl_2_butene: 84.7, //二甲基乙烯
		C_Isopentane: 90.3, //异戊烷
		C_N_pentane: 62.6, //正戊烷

	}
};

function converts(type, values) {
				var result = [];
				//return type
				//return convert_table.A
				console.log(values)
				switch (type) {
					case 'vv2mm':
						var tmp = [];
						var sum_vv = 0; //气体百分比总和，正常为100
						var sum_mm = 0; //换算后质量百分比总和，很大
						var sum_mm_100 = 0; //折算为100%后的总和，由于修约，会导致多一点或少一点
						var ratio = 0; //比率
						var i = 0
						for (var p in values.vv) {
							tmp[p] = Number(values.vv[p]) * Number(convert_table.A[p])
							//console.log(values.vv[p])
							sum_mm += Number(tmp[p])
							sum_vv += Number(values.vv[p])
						}
						for (var q in tmp) {
							values.mm[q] = (Number(tmp[q] * 100) / Number(sum_mm)).toFixed(2)
							sum_mm_100 += Number(values.mm[q])
						}
						// vv_sum = sum_vv
						// mm_sum = sum_mm_100
						result = {'sum_vv':sum_vv,'sum_mm':sum_mm_100,result:values}
						return result
						break;
					case 'vv2ml':
						var tmp = [];
						var sum_vv = 0; //气体百分比总和，正常为100
						var sum_ml = 0; //换算后液体百分比总和，很大
						var sum_ml_100 = 0; //折算为100%后的总和，由于修约，会导致多一点或少一点
						var ratio = 0; //比率
						var i = 0
						for (var p in values.vv) {
							tmp[p] = Number(values.vv[p]) * Number(convert_table.B[p])
							//console.log(values.vv[p])
							sum_ml += Number(tmp[p])
							sum_vv += Number(values.vv[p])
						}
						for (var q in tmp) {
							values.ml[q] = (Number(tmp[q] * 100) / Number(sum_ml)).toFixed(2)
							sum_ml_100 += Number(values.ml[q])
						}
						//vv_sum = sum_vv
						//ml_sum = sum_ml_100
						result = {'sum_vv':sum_vv,'sum_ml':sum_ml_100,result:values}
						return result
						break;
					case 'mm2vv':
						var tmp = [];
						var sum_mm = 0; //质量百分比总和，正常为100
						var sum_vv = 0; //换算后气体百分比总和，很大
						var sum_vv_100 = 0; //折算为100%后的总和，由于修约，会导致多一点或少一点
						var ratio = 0; //比率
						var i = 0
						for (var p in values.mm) {
							tmp[p] = Number(values.mm[p]) / Number(convert_table.A[p])
							//console.log(values.vv[p])
							sum_vv += Number(tmp[p])
							sum_mm += Number(values.mm[p])
						}
						for (var q in tmp) {
							values.vv[q] = (Number(tmp[q] * 100) / Number(sum_vv)).toFixed(2)
							sum_vv_100 += Number(values.vv[q])
						}
						// mm_sum = sum_mm
						// vv_sum = sum_vv_100
						result = {'sum_mm':sum_mm,'sum_vv':sum_vv_100,result:values}
						return result
						break;
					case 'mm2ml':
						var tmp = [];
						var sum_mm = 0; //质量百分比总和，正常为100
						var sum_ml = 0; //换算后气体百分比总和，很大
						var sum_ml_100 = 0; //折算为100%后的总和，由于修约，会导致多一点或少一点
						var ratio = 0; //比率
						var i = 0
						for (var p in values.mm) {
							tmp[p] = Number(values.mm[p]) / Number(convert_table.C[p])
							//console.log(values.vv[p])
							sum_ml += Number(tmp[p])
							sum_mm += Number(values.mm[p])
						}
						for (var q in tmp) {
							values.ml[q] = (Number(tmp[q] * 100) / Number(sum_ml)).toFixed(2)
							sum_ml_100 += Number(values.ml[q])
						}
						// mm_sum = sum_mm
						// ml_sum = sum_ml_100
						result = {'sum_mm':sum_mm,'sum_ml':sum_ml_100,result:values}
						return result
						break;
					case 'ml2vv':
						var tmp = [];
						var sum_ml = 0; //质量百分比总和，正常为100
						var sum_vv = 0; //换算后气体百分比总和，很大
						var sum_vv_100 = 0; //折算为100%后的总和，由于修约，会导致多一点或少一点
						var ratio = 0; //比率
						var i = 0
						for (var p in values.ml) {
							tmp[p] = Number(values.ml[p]) / Number(convert_table.B[p])
							//console.log(values.vv[p])
							sum_vv += Number(tmp[p])
							sum_ml += Number(values.ml[p])
						}
						for (var q in tmp) {
							values.vv[q] = (Number(tmp[q] * 100) / Number(sum_vv)).toFixed(2)
							sum_vv_100 += Number(values.vv[q])
						}
						// ml_sum = sum_ml
						// vv_sum = sum_vv_100
						result = {'sum_ml':sum_ml,'sum_vv':sum_vv_100,result:values}
						return result
						break;
					case 'ml2mm':
						var tmp = [];
						var sum_ml = 0; //质量百分比总和，正常为100
						var sum_mm = 0; //换算后气体百分比总和，很大
						var sum_mm_100 = 0; //折算为100%后的总和，由于修约，会导致多一点或少一点
						var ratio = 0; //比率
						var i = 0
						for (var p in values.ml) {
							tmp[p] = Number(values.ml[p]) * Number(convert_table.C[p])
							//console.log(values.mm[p])
							sum_mm += Number(tmp[p])
							sum_ml += Number(values.ml[p])
						}
						for (var q in tmp) {
							values.mm[q] = (Number(tmp[q] * 100) / Number(sum_mm)).toFixed(2)
							sum_mm_100 += Number(values.mm[q])
						}
						// ml_sum = sum_ml
						// mm_sum = sum_mm_100
						result = {'sum_ml':sum_ml,'sum_mm':sum_mm_100,result:values}
						return result
						break;
					case 'calc':
						var tmp_vp = [];
						var sum_vp = 0;
						var tmp_des = [];
						var sum_des = 0;
						var tmp_mon = [];
						var sum_mon = 0;
						var result = [];
						for (var p in values.ml) {
							//计算蒸气压
							tmp_vp[p] = Number(values.ml[p]) * Number(calc_table.A[p]) / 100
							sum_vp += tmp_vp[p]
							//计算密度
							tmp_des[p] = (Number(values.ml[p]) * Number(calc_table.B[p])) * 0.9990 / 100
							sum_des += tmp_des[p]
							//计算马达法辛烷值
							tmp_mon[p] = Number(values.ml[p]) * Number(calc_table.C[p]) / 100
							sum_mon += tmp_mon[p]
						}
						result = {'vp':sum_vp.toFixed(4),'des':sum_des.toFixed(4),'mon':sum_mon.toFixed(4)}
						return result
					default:
						break;
				}
			}




function add(a, b) {
	console.log("调用了fun1的add方法");
	console.log(a + b);
	return 'xxx'
}

module.exports = {
	converts,
	add
}
